package com.bw.eureka.jpa.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.List;

@Entity
@Table(name = "user")
public class UserEntity {
    private Integer id;
    private String name;
    private String phone;
    private String telephone;
    private String address;
    private Byte enabled;
    private String username;
    private String password;
    private String userface;
    private String remark;
    private Byte sex;
    private Integer province;
    private Integer city;
    private Integer district;
    private Timestamp createTime;
    private Integer cardId;
    private Integer age;


    private UserCardEntity cardEntity;




    @JsonIgnoreProperties(value = {"userEntity"})
    @OneToOne()
    @JoinColumn(name = "card_id",referencedColumnName = "id",updatable = false,insertable = false)
    public UserCardEntity getCardEntity() {
        return cardEntity;
    }

    public void setCardEntity(UserCardEntity cardEntity) {
        this.cardEntity = cardEntity;
    }


    private List<TdOrderEntity> tdOrderEntity;


    private List<RoleEntity>  roles;

    @JsonIgnoreProperties(value = {"userEntityList"})
    @ManyToMany()
    @JoinTable(name = "user_role",inverseJoinColumns = @JoinColumn(name = "rid"),joinColumns = @JoinColumn(name = "uid"))
    public List<RoleEntity> getRoles() {
        return roles;
    }

    public void setRoles(List<RoleEntity> roles) {
        this.roles = roles;
    }

    @JsonIgnoreProperties(value = {"userEntity"})
    @OneToMany(mappedBy = "userEntity",cascade = CascadeType.DETACH)
    public List<TdOrderEntity> getTdOrderEntity() {
        return tdOrderEntity;
    }

    public void setTdOrderEntity(List<TdOrderEntity> tdOrderEntity) {
        this.tdOrderEntity = tdOrderEntity;
    }

    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Basic
    @Column(name = "name", nullable = true, length = 32)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Basic
    @Column(name = "phone", nullable = true, length = 11)
    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    @Basic
    @Column(name = "telephone", nullable = true, length = 16)
    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    @Basic
    @Column(name = "address", nullable = true, length = 64)
    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Basic
    @Column(name = "enabled", nullable = true)
    public Byte getEnabled() {
        return enabled;
    }

    public void setEnabled(Byte enabled) {
        this.enabled = enabled;
    }

    @Basic
    @Column(name = "username", nullable = true, length = 255)
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Basic
    @Column(name = "password", nullable = true, length = 255)
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Basic
    @Column(name = "userface", nullable = true, length = 255)
    public String getUserface() {
        return userface;
    }

    public void setUserface(String userface) {
        this.userface = userface;
    }

    @Basic
    @Column(name = "remark", nullable = true, length = 255)
    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Basic
    @Column(name = "sex", nullable = true)
    public Byte getSex() {
        return sex;
    }

    public void setSex(Byte sex) {
        this.sex = sex;
    }

    @Basic
    @Column(name = "province", nullable = true)
    public Integer getProvince() {
        return province;
    }

    public void setProvince(Integer province) {
        this.province = province;
    }

    @Basic
    @Column(name = "city", nullable = true)
    public Integer getCity() {
        return city;
    }

    public void setCity(Integer city) {
        this.city = city;
    }

    @Basic
    @Column(name = "district", nullable = true)
    public Integer getDistrict() {
        return district;
    }

    public void setDistrict(Integer district) {
        this.district = district;
    }

    @Basic
    @Column(name = "create_time", nullable = true)
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "card_id", nullable = true)
    public Integer getCardId() {
        return cardId;
    }

    public void setCardId(Integer cardId) {
        this.cardId = cardId;
    }

    @Basic
    @Column(name = "age", nullable = true)
    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }


}
